package com.talkweb.yingu.apimodel.admin;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import sun.invoke.util.VerifyAccess;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by qsf on 2019/4/3.
 */
@Setter
@Getter
public class SysMenuVo implements Serializable{
    private static final long serialVersionUID=1L;

    @ApiModelProperty(value="主键")
    private Long id;
    @ApiModelProperty(value="MENU_CODE")
    private String menuCode;
    @ApiModelProperty(value="MENU_NAME")
    private String menuName;
    @ApiModelProperty(value="MENU_ICON")
    private String menuIcon;
    @ApiModelProperty(value="MENU_URL")
    private String menuUrl;
    @ApiModelProperty(value="PARENT_ID")
    private String parentId;
    @ApiModelProperty(value="ORDER_BY")
    private String orderBy;
    @ApiModelProperty(value="VALIDATE_STATE")
    private String validateState;
    @ApiModelProperty(value="APP_ID")
    private Long appId;  ///??decimal(18,0)
    @ApiModelProperty(value="VERSION")
    private Long version;   //??
    @ApiModelProperty(value="RESOURCE_ID")
    private Long resourceId;  //??
    @ApiModelProperty(value="IS_SHOW")
    private int isShow;     //是否显示菜单

    public static List<TreeNodeVo> toTreeModel(List<SysMenuVo> list) {
        List<TreeNodeVo> nodeList = new ArrayList<>();
        for(SysMenuVo sysMenuVo: list) {
            TreeNodeVo treeNode = new TreeNodeVo();
            treeNode.setId(sysMenuVo.getId().toString());
            treeNode.setName(sysMenuVo.getMenuName());
            treeNode.setParentId(sysMenuVo.getParentId());
            nodeList.add(treeNode);
        }
        return TreeNodeVo.treeBuild(nodeList);
    }
}
